home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / click / click.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-20  |  1.6 KB  |  64 lines

  1. /* 
  2.  * click.c --
  3.  *
  4.  *    This file contains a program that will turn the key click on or off.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /a/newcmds/click/RCS/click.c,v 1.2 89/07/20 10:40:49 ouster Exp $ SPRITE
  18.  (Berkeley)";
  19. #endif not lint
  20.  
  21. #include <sys/file.h>
  22. #include <stdio.h>
  23.  
  24. main(argc, argv)
  25.     int        argc;
  26.     char    **argv;
  27. {
  28.     char        buf[100];
  29.     int            i;
  30.     int            fd;
  31.  
  32.     if (argc != 2) {
  33.     fprintf(stderr, "click [on | off]\n");
  34.     exit(1);
  35.     }
  36.     if (strcmp(argv[1], "on") == 0) {
  37.     buf[0] = 0xa;
  38.     } else if (strcmp(argv[1], "off") == 0) {
  39.     buf[0] = 0xb;
  40.     } else {
  41.     fprintf(stderr, "click [on | off]\n");
  42.     exit(1);
  43.     }
  44.  
  45.     /*
  46.      * For now (7/20/89) try both /dev/mouse and dev/Xevent, to support
  47.      * both the old and new versions of X.  However, in a few weeks it
  48.      * should be possible to get rid of /dev/Xevent.
  49.      */
  50.  
  51.     fd = open("/dev/mouse", O_WRONLY, 0);
  52.     if (fd < 0) {
  53.     fd = open("/dev/Xevent", O_WRONLY, 0);
  54.     }
  55.     if (fd < 0) {
  56.     perror("Click: couldn't open /dev/mouse or /dev/Xevent");
  57.     exit(1);
  58.     }
  59.     if (write(fd, buf, 1) != 1) {
  60.     perror("Click: write to /dev/mouse");
  61.     exit(1);
  62.     }
  63. }
  64.